﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core
{
    public static partial class system
    {
        public static dynamic getSystemSettings()
        {
            var sql = new Sql.SqlDataContext();
            var s = sql.Settings.FirstOrDefault();
            if (s == null)
            {
                s = new Sql.Settings
                {
                    id = 1,
                    title = "合肥工业大学 OnlineJudge",
                    copyright = "计算机与信息学院 (C) 2010",
                    openAccess = true,
                    openDiscuss = true,
                    openOutsideDiscuss = true,
                    openOutsideReg = true,
                    openOutsideSendMsg = true
                };
                sql.Settings.InsertOnSubmit(s);
                sql.SubmitChanges();
            }
            return new
            {
                success = true,
                s.title,
                s.copyright,
                s.openAccess,
                s.openDiscuss,
                s.openOutsideDiscuss,
                s.openOutsideReg,
                s.openOutsideSendMsg
            };
        }
    }
}
